package com.hejjon.core.enumer;

import lombok.Getter;

@Getter
public enum DataViewTypeEnum {

    NUMBER("number", "数值"),

    CHARACTER("character", "字符"),

    DATE("date", "日期"),

    TIME("datetime", "时间");

    private final String code;

    private final String desc;

    DataViewTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getCodeByTypeName(String typeName) {
        BasicTypeEnum bt = BasicTypeEnum.getByCode(typeName);
        switch (bt) {
            case DATE:
                return DATE.code;
            case DATE_TIME:
                return TIME.code;
            case INT:
            case DOUBLE:
                return NUMBER.code;
            default:
                return CHARACTER.code;
        }
    }

    public static Boolean getIsDate(String jdbcType) {
        return JdbcTypeEnum.DATE.getCode().equalsIgnoreCase(jdbcType)
                || JdbcTypeEnum.DATETIME.getCode().equalsIgnoreCase(jdbcType);
    }

    public static Boolean getIsNumber(String jdbcType) {
        return JdbcTypeEnum.INT.getCode().equalsIgnoreCase(jdbcType)
                || JdbcTypeEnum.BIGINT.getCode().equalsIgnoreCase(jdbcType)
                || JdbcTypeEnum.DOUBLE.getCode().equalsIgnoreCase(jdbcType);
    }


}
